package com.lihao.jetpackcore.network.manager

import me.hgj.jetpackmvvm.callback.livedata.UnPeekLiveData

/**
 * Created by lihao on 2020/5/14.
 * Describe: 网络变化管理者
 */
class NetworkStateManager private constructor() {

    val mNetworkStateCallback = UnPeekLiveData<NetState>()

    init {
        if (mNetworkStateCallback.value == null || !mNetworkStateCallback.value!!.isSuccess) {
            mNetworkStateCallback.postValue(
                NetState(
                    isSuccess = true
                )
            )
        }
    }

    companion object {
        val instance: NetworkStateManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
            NetworkStateManager()
        }
    }
}